/**
 * Created by yuzhou on 2020/3/29.
 */
//获取
$(document).ready(function () {
    var app = new Vue({
        el: "#whole_box",
        data: {
            input_txt1:"姓名",
            input_txt2:"电话",
            input_txt3:"咨询事项",

            input_name:"",
            input_phone:"",
            input_msg:"",

            market_id:1,

            title_txt:"联系我们",
            tab1:"信基沙溪(广州)",
            tab2:"信基豪泰(广州)",
            tab3:"信基沙溪(沈阳)",
            onlineMsg_txt:"在线留言",
            email_txt:"邮箱",
            cline_txt:"客服热线",
            iline_txt:"招商热线",
            address_txt:"地址",
            submit_txt:"提交留言",
            address1:"",
            address2:"",
            address3:"",
            one:"市场导购",
            two:"动态资讯",
            three:"联系我们",
            three_box_txt_show:true,

        },
        mounted:function(){
            var self = this;
            var language = localStorage.getItem("language");
            if(language == "cn"){
                self.changeToCn();
            }else{
                self.changeToEn();
            }
            //self.changeToEn();

        },
        methods: {
            changeToEn:function () {
                var self = this;
                self.three_box_txt_show = false;
                self.one = "MarketShopping"+"\n"+"Guide";
                self.two = "Dynamic"+"\n"+"Information";
                self.three = "Contact Us";
                self.input_txt1 = "Name";
                self.input_txt2 = "Phone";
                self.input_txt3 = "Advisory matters";
                self.title_txt = "Contact Us";
                self.tab1 = "Xinji Shaxi (Guangzhou)";
                self.tab2 = "Xinji Hotelex (Guangzhou)";
                self.tab3 = "Xinji Shaxi (Shenyang)";
                self.onlineMsg_txt = "Online Message";
                self.email_txt = "E-mail";
                self.cline_txt = "Customer hotline";
                self.iline_txt = "Investment hotline";
                self.address_txt = "Address";
                self.submit_txt = "Submit";
                self.address1 = "Shaxi Exit of Hua-Nan Expressway, Shaxi Avenue, Panyu District, Guangzhou, Guangdong Province";
                self.address2 = "Exit A/B of Xiajiao Metro Station, Xinguang Expressway, Yingbin Road, Panyu District, Guangzhou, Guangdong Province";
                self.address3 = "No. 59, North Daoyi Street, Shenbei New District, Shenyang,  Liaoning Province";
            },
            changeToCn:function () {
                var self = this;
                self.input_txt1 = "姓名";
                self.input_txt2 = "电话";
                self.input_txt3 = "咨询事项";
                self.title_txt = "联系我们";
                self.tab1 = "信基沙溪(广州)";
                self.tab2 = "信基豪泰(广州)";
                self.tab3 = "信基沙溪(沈阳)";
                self.onlineMsg_txt = "在线留言";
                self.email_txt = "邮箱";
                self.cline_txt = "客服热线";
                self.iline_txt = "招商热线";
                self.address_txt = "地址";
                self.submit_txt = "提交留言";
                self.address1 = "广州番禺区沙溪大道华南快速干线番禺大桥沙溪出口（信基沙溪酒店用品博览城）";
                self.address2 = "广州番禺区迎宾路新光快线地铁3号线厦滘A、B出口（信基豪泰酒店用品城）";
                self.address3 = "沈阳市沈北新区道义北大街59-1号";
                self.one = "市场导购";
                self.two = "动态资讯";
                self.three = "联系我们";
                self.three_box_txt_show = true;
            },

            changeTab:function (a) {
                var self = this;
                if(a == 1){
                    self.input_name = "";
                    self.input_phone = "";
                    self.input_msg = "";
                    self.market_id = 1;
                }else if(a == 2){
                    self.input_name = "";
                    self.input_phone = "";
                    self.input_msg = "";
                    self.market_id = 2;
                }else if(a == 3){
                    self.input_name = "";
                    self.input_phone = "";
                    self.input_msg = "";
                    self.market_id = 3;
                }
            },

            submitMsg:function(){
                var self = this;
                if(self.input_name == ""||self.input_phone == ""||self.input_msg == ""){
                   alert("信息填写不完整！");
                }else{
                    $.ajax({
                        type:"GET",
                        url:"/msg/submitMsg",
                        data: {
                            market_id:self.market_id,
                            name:self.input_name,
                            phone:self.input_phone,
                            msg:self.input_msg
                        },
                        dataType:"json",
                        success:function(res){
                            if(res){
                                alert("提交成功");
                                window.location.reload();
                            }

                        }
                    });
                }

            },


        },

    });
});